package com.itheima.controller;

import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.OrderStatusDTO;
import com.itheima.pojo.OrderVO;
import com.itheima.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/order")
@Api(tags = "预约列表相关接口")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 预约列表分页查询
     * @param queryPageBean
     * @return
     */
    @PostMapping("/findPage")
    @ApiOperation("预约列表分页查询")
    public Result<PageResult> page(@RequestBody QueryPageBean queryPageBean){
        log.info("预约列表分页查询：{}", queryPageBean);
        PageResult pageResult = orderService.pageQuery(queryPageBean);
        return Result.success(pageResult);
    }

    /**
     * 修改预约状态
     * @param orderStatusDTO
     * @return
     */
    @PutMapping("/update")
    @ApiOperation("修改预约状态")
    public Result update (@RequestBody OrderStatusDTO orderStatusDTO) {
        log.info("修改预约状态:{}",orderStatusDTO);
        orderService.updateById(orderStatusDTO);
        return Result.success();
    }

}
